import { createRouter, createWebHistory } from 'vue-router'
import Layout from '../layout/Layout.vue'
import Backend from "@/layout/Backend.vue";

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect:"/home",
    children: [
      {
        path:'home',
        name:'Home',
        component: () => import("@/views/Home"),
      }
    ]
  },

  {
    path: '/login',
    name: 'Login',
    component: () => import("@/views/Login")
  },
  {
    path: '/backend-login',
    name: 'Backend-Login',
    component: () => import("@/backstage/Backend_Login.vue")
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import("@/views/Register.vue")
  },
  {
    path:'/buy',
    name:'Buy',
    component: () => import("@/views/Buy.vue"),
  },
  {
    path:'/myspace',
    name:'Myspace',
    component: () => import("@/components/Myspace.vue"),
  },
  {
    path:'/product/:id',
    name:'Product',
    component: () => import("@/components/Product.vue"),
    props: true,
  },
  {
    path:'/userPassword',
    name:'UserPassword',
    component: () => import("@/components/UserPassword.vue"),
  },
  {
    path:'/showcart',
    name:'Showcart',
    component: () => import("@/components/Showcart.vue"),
    props: true,
  },
  {
    path:'/search',
    name:'Search',
    component: () => import("@/components/Search.vue"),
    props: true,
  },
  {
    path:'/mypurchase',
    name:'Mypurchase',
    component: () => import("@/components/Mypurchase.vue"),
  },
  {
    path: '/Backend',
    name: 'Backend',
    component: Backend,
    redirect:"/Backend/user",
    meta:{breadcrumb:"首页"},
    children: [
      {
        path:'employee',
        name:'BackendEmployee',
        meta: { breadcrumb: '员工管理' },
        component: () => import("@/backstage/Employee.vue"),
      },
      {
        path:'user',
        name:'BackendUser',
        meta: { breadcrumb: '用户管理' },
        component: () => import("@/backstage/User.vue"),
      },
      {
        path:'flower',
        name:'BackendFlower',
        meta: { breadcrumb: '鲜花管理' },
        component: () => import("@/backstage/Flower.vue"),
      },
      {
        path:'order',
        name:'BackendOrder',
        meta: { breadcrumb: '订单管理' },
        component: () => import("@/backstage/Order.vue"),
      },
      {
        path:'classification',
        name:'BackendOrderitem',
        meta: { breadcrumb: '种类管理' },
        component: () => import("@/backstage/Classification.vue"),
      },
      {
        path:'employeePerson',
        name:'EmployeePerson',
        meta: { breadcrumb: '个人信息' },
        component: () => import("@/backstage/EmployeePerson.vue"),
      },
      {
        path:'updatePassword',
        name:'UpdatePassword',
        meta: { breadcrumb: '修改密码' },
        component: () => import("@/backstage/UpdatePassword.vue"),
      },
    ]
  },
]


const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
